{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is to get a part of the original LC data, which is too big to be handled on my laptop. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Imports\n",
    "import pandas as pd\n",
    "from pandas import Series, DataFrame\n",
    "import pandas_profiling\n",
    "\n",
    "import numpy as np\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/yanxia/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py:2785: DtypeWarning: Columns (0,18,48,58,117,128,129,130,133,134,135,138,144,145,146) have mixed types. Specify dtype option on import or set low_memory=False.\n",
      "  interactivity=interactivity, compiler=compiler, result=result)\n"
     ]
    }
   ],
   "source": [
    "df = pd.read_csv('../input/accepted_2007_to_2017Q3.csv.gz',compression='gzip',low_memory=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 1646801 entries, 0 to 1646800\n",
      "Columns: 150 entries, id to settlement_term\n",
      "dtypes: float64(113), object(37)\n",
      "memory usage: 1.8+ GB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Mar-2016    61992\n",
       "Oct-2015    48631\n",
       "Jul-2015    45962\n",
       "Dec-2015    44343\n",
       "Aug-2017    43573\n",
       "Sep-2017    39713\n",
       "Feb-2016    39529\n",
       "Jul-2017    39415\n",
       "Oct-2014    38783\n",
       "Jun-2017    38087\n",
       "May-2017    37681\n",
       "Nov-2015    37530\n",
       "Mar-2017    37181\n",
       "Apr-2016    36432\n",
       "Aug-2016    36280\n",
       "Dec-2016    36183\n",
       "Aug-2015    35886\n",
       "Apr-2015    35427\n",
       "Jan-2015    35107\n",
       "Jul-2016    34696\n",
       "Nov-2016    34591\n",
       "Jun-2016    33019\n",
       "Oct-2016    32772\n",
       "Jan-2016    32366\n",
       "May-2015    31913\n",
       "Jan-2017    31835\n",
       "Apr-2017    29683\n",
       "Jul-2014    29306\n",
       "Sep-2015    28641\n",
       "Jun-2015    28485\n",
       "            ...  \n",
       "Oct-2009      604\n",
       "Sep-2009      507\n",
       "Aug-2009      446\n",
       "Jul-2009      411\n",
       "Jun-2009      406\n",
       "Mar-2008      402\n",
       "May-2009      359\n",
       "Apr-2009      333\n",
       "Mar-2009      324\n",
       "Feb-2008      306\n",
       "Jan-2008      305\n",
       "Feb-2009      302\n",
       "Jan-2009      269\n",
       "Apr-2008      259\n",
       "Dec-2008      253\n",
       "Nov-2008      209\n",
       "Dec-2007      172\n",
       "Jul-2008      141\n",
       "Jun-2008      124\n",
       "Oct-2008      122\n",
       "May-2008      115\n",
       "Nov-2007      112\n",
       "Oct-2007      105\n",
       "Aug-2008      100\n",
       "Aug-2007       74\n",
       "Jul-2007       63\n",
       "Sep-2008       57\n",
       "Sep-2007       53\n",
       "Jun-2007       24\n",
       "NaN            23\n",
       "Name: issue_d, Length: 125, dtype: int64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['issue_d'].value_counts(dropna=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_2017 = df[df['issue_d'].str.contains(\"2017\",na=False)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Aug-2017    43573\n",
       "Sep-2017    39713\n",
       "Jul-2017    39415\n",
       "Jun-2017    38087\n",
       "May-2017    37681\n",
       "Mar-2017    37181\n",
       "Jan-2017    31835\n",
       "Apr-2017    29683\n",
       "Feb-2017    27763\n",
       "Name: issue_d, dtype: int64"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_2017['issue_d'].value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "writing output file...\n"
     ]
    }
   ],
   "source": [
    "print('writing output file...')\n",
    "df_2017.to_csv('../input/accepted_2017.csv.gz', index=False, compression='gzip')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
